package com.leizi.igym.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Author: leizi0110
 * @CreateTime: 2024-04-29  18:20
 * @Description:
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Document(indexName = "post")
public class PostESDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 514442932077534862L;

    @JsonSerialize(using = ToStringSerializer.class)
    @Id
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @Field(type = FieldType.Keyword,index = false)
    private Long userId;

    @Field(type = FieldType.Keyword,index = false)
    private String pictures;

    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String title;

    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String nickname;

    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String content;

    @Field(type = FieldType.Date,format ={},pattern = "yyyy-MM-dd HH:mm:ss" )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Field(type = FieldType.Keyword,index = false)
    private String avatar;

    @Field(type = FieldType.Integer)
    private Integer likeNum;

    @Field(type = FieldType.Integer)
    private Integer collectNum;
}
